package com.qf.admin.http;

public class Result<T> {

//    private int code ;
    private boolean success ;
    private T data;
    private String description;

//    public int getCode() {
//        return code;
//    }
//
//    public void setCode(int code) {
//        this.code = code;
//    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Result() {
    }

    public Result(boolean success, T data, String description) {
        this.success = success;
        this.data = data;
        this.description = description;
    }

    public static <T> Result<T> success(){
        return new Result<>(ResultCode.SUCCESS.isSuccess() , null , null);
    }

    public static <T> Result<T> success(T data){
        return new Result<>(ResultCode.SUCCESS.isSuccess() , data , ResultCode.SUCCESS.getDescription());
    }

    public static Result<?> error() {
        return new Result<>(ResultCode.FAIL.isSuccess() , null , ResultCode.LOGIN_ERROR.getDescription());
    }



}
